﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.IO;

namespace Sinacor.Servico.Infra.FileTransfer.Service.DataContract.Request
{
    [MessageContract(WrapperNamespace = "http://www.bovespa.com.br/Sinacor.Servico.Infra.FileTransfer.Service.DataContract.Request", WrapperName = "FileInfoRequest")]
    public class FileInfoRequest : IDisposable
    {
        private string _fileName;
        private string _processName;
        private Stream _dataStream;
        private CompressionBehavior _compressionBehavior = CompressionBehavior.Disabled;

        [MessageHeader(MustUnderstand = true)]
        public string FileName
        {
            get { return _fileName; }
            set { _fileName = value; }
        }        

        [MessageHeader(MustUnderstand = true)]
        public string ProcessName
        {
            get { return _processName; }
            set { _processName = value; }
        }

        [MessageHeader(MustUnderstand = true)]
        public CompressionBehavior CompressionBehavior
        {
            get { return _compressionBehavior; }
            set { _compressionBehavior = value; }
        }

        [MessageBodyMember(Order = 1)]
        public Stream DataStream
        {
            get { return _dataStream; }
            set { _dataStream = value; }
        }

        public void Dispose()
        {
            if (_dataStream != null)
            {
                _dataStream.Close();
                _dataStream = null;
            }
        }
    }
}
